package com.csj.lc.service;

import cn.hutool.crypto.SecureUtil;
import com.csj.lc.base.BaseService;
import com.csj.lc.entity.Company;
import com.csj.lc.entity.Operation;
import com.csj.lc.entity.Role;
import com.csj.lc.entity.User;
import com.csj.lc.entity.dto.LayuiDTO;
import com.csj.lc.entity.dto.ReturnDTO;
import com.csj.lc.entity.dto.SearchDTO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;


@Service
@Transactional
public class CompanyService extends BaseService {

    public LayuiDTO<Company> getList(HttpServletRequest request, Model model, int pageNo, int pageSize) {

        int startPos = (pageNo - 1 ) * pageSize;
        List<Company> companyList = companyMapper.getList( startPos , pageSize );

        LayuiDTO<Company> result = new LayuiDTO<Company>();
        if(companyList!= null && companyList.size()>0 ){
            result.setCode(0);
            result.setMsg("成功获取公司列表");
            result.setData(companyList);
            result.setCount(companyMapper.getCount());
        }else{
            result.setCode(-1);
            result.setCount(0);
            result.setMsg( "公司列表为空");
            result.setData(null);
        }
        return result;

    }
}
